<?php

namespace app\common\model\user;

use app\common\model\Model;
use traits\model\SoftDelete;

class School extends Model
{
    use SoftDelete;

    // 表名
    protected $name = 'user_school';

    // 追加属性
    protected $append = [
        'status_name'
    ];

    const STATUS_WAIT = 1;
    const STATUS_PASS = 2;
    const STATUS_REFUSE = 3;

    const STATUS = [
        self::STATUS_WAIT => '待审核',
        self::STATUS_PASS => '审核通过',
//        self::STATUS_REFUSE => '审核拒绝',
    ];

    public function getStatusNameAttr($value, $data)
    {
        return self::STATUS[$data['status']] ?? '';
    }

    public function school()
    {
        return $this->hasOne('app\common\model\School', 'id', 'school_id');
    }

    public function user()
    {
        return $this->hasOne('app\common\model\User', 'id', 'user_id');
    }
}
